﻿<%@ Control Language="VB" AutoEventWireup="false" CodeFile="PostWrite.ascx.vb" Inherits="App_Controls_PostWrite" %>

<%--<link href="/js/ajaxuploader/fileuploader.css" rel="stylesheet" type="text/css" />--%>

<asp:ScriptManagerProxy runat="server" ID="ScrManProxy">
    <Scripts>
        <%--<asp:ScriptReference Path="~/js/ajaxuploader/fileuploader.js" />--%>
    </Scripts>
</asp:ScriptManagerProxy>

<asp:PlaceHolder runat="server" ID="PlhJavaScript">
    <script type="text/javascript">

        $max = 140;


        $('#<% = Me.TxtPost.ClientID%>').keyup(function () {

            post_text = $('#<% = Me.TxtPost.ClientID%>').val();
            //post_text = post_text.replace(/((http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&amp;:/~\+#]*[\w\-\@?^=%&amp;/~\+#])?)/, '1234567890123456789012');
            //post_text = post_text.replace(/((http|ftp|https):\/\/[\w\-_])?(\.[\w\-_]+)+([\w\-\.,@?^=%&amp;:/~\+#]*[\w\-\@?^=%&amp;/~\+#])?/, '1234567890123456789012');
            //post_text = post_text.replace(/(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/, '1234567890123456789012');
            //post_text = post_text.replace(/(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*(\.(\w){2})+\/?$/, '1234567890123456789012');
            post_text = post_text.replace(/(https?:\/\/)?[\w\-_]+(\.[\w\-_]+)+(\.[\w\-_]+)+[\w\-\.,@?^=%&amp;:/~\+#]*/, '1234567890123456789012');
            //alert(post_text);
            //$('#CphMainContent_ppp2_LblMediaName').html(post_text);
            $len2 = post_text.length;
            
            $('#<% = Me.countBox.ClientID %>').text($max - $len2)
            if ($max - $len2 < 0) {

                $str = $('#<% = Me.TxtPost.ClientID%>').val();
                $str = $str.substring(0, $max)
                //                    $('#<% = Me.TxtPost.ClientID%>').val($str)
                $('#<% = Me.countBox.ClientID %>').text(0)

            }
        });

        if ($('#<% = Me.HTML_Fileuploader.ClientID%>').length > 0) {

            new qq.FileUploader({
                element: $('#<% = Me.HTML_Fileuploader.ClientID%>')[0],
                //element: $('imageUpload'),
                action: '/App/MediaUpload.aspx',
                uploadButtonText: '',
                hideDropzones: true,
                onSubmit: function (file, extension) {

                },
                onProgress: function (id, fileName, loaded, total) {

                },
                onComplete: function (id, fileName, responseJSON) {

                    if (responseJSON.success) {
                        //alert("Success, imported " + responseJSON.rows);
                    } else {
                        alert("Error");
                    }
                    //alert(responseJSON.image_id);
                    //alert('<% = Me.HidImageID.ClientID%>');
                    //__doPostBack('<% = BtnReload_UpPPost.UniqueID %>', '');
                    $("#<% = Me.HidImageID.ClientID%>").val(responseJSON.image_id)
                    $("#<% = Me.BtnReload_UpPPost.ClientID%>").click();

                },
                onError: function (id, fileName, reason) {
                    //alert("Errore nel importazione del file");

                }

            });
        }


    </script>
</asp:PlaceHolder>




<%--<div class="message-absolute">
    <div class="listen-testo">
        <textarea name="tweet" class="listen-text"></textarea></div>
    <div class="listen-num-crt">140</div>
    <div class="listen-private-message">
        <div class="message-icona">
            <a class="a-icona-upload-h tooltip" title="Tips Icon" href="#"></a>pippo.jpg<a class="a-icona-x tooltip" title="Tips Icon" href="#"></a>
        </div>
        <div class="message-check">
            <input id="sent-2" type="checkbox" name="sent-2">
            <label for="sent-2">
                <span></span>
                private message
            </label>
        </div>
        <div class="option-sent">
            <a class="bottone-save" href="#">Send</a>
        </div>
    </div>
</div>

<hr />--%>

<div class="message-absolute">
    <asp:Button ID="BtnReload_UpPPost" ClientIDMode="AutoID" runat="server" Style="display: none;" Text="Reload" />
    <asp:HiddenField runat="server" ID="HidAccount" />
    <div class="listen-testo">
        <asp:TextBox runat="server" ID="TxtPost" CssClass="listen-text" TextMode="MultiLine" ClientIDMode="AutoID"></asp:TextBox>
    </div>
    <div class="listen-num-crt">
        <asp:Label runat="server" ID="countBox" Text="140"></asp:Label>
    </div>
    <div class="listen-private-message">
        <div class="message-icona">
            <%-- <a class="a-icona-upload-h tooltip" title="Tips Icon" href="#"></a>pippo.jpg<a class="a-icona-x tooltip" title="Tips Icon" href="#"></a>--%>

            <asp:Panel CssClass="a-icona-foto tooltip tooltip" runat="server" ID="HTML_Fileuploader"></asp:Panel>
            <asp:Image runat="server" ID="ImgPost" Style="max-height: 200px; max-width: 200px" Visible="false" />
            <asp:Label runat="server" ID="LblMediaName"></asp:Label>
            <asp:LinkButton runat="server" ID="BtnDeleteMedia" class="a-icona-x tooltip" title="Tips Icon"></asp:LinkButton>
            <asp:HiddenField runat="server" ID="HidImageID" ClientIDMode="AutoID" />

        </div>
        <asp:Panel runat="server" ID="PnlPrivate" class="message-check">
            <asp:CheckBox runat="server" ID="ChkPrivatePost" />
            <label for="<%= Me.ChkPrivatePost.ClientID%>">
                <span></span>
                private message
            </label>
        </asp:Panel>
        <div class="option-sent">
            <asp:LinkButton runat="server" ID="BtnReply" CssClass="bottone-save" Text="Send" />
        </div>
    </div>
    <asp:TextBox runat="server" ID="TxtToAccountName" Visible="false"></asp:TextBox>
    <asp:Label runat="server" ID="LblTitle" Visible="false"></asp:Label>
    <asp:Label runat="server" ID="LblResult" ViewStateMode="Disabled" Style="color: red;" Visible="false" Text="error"></asp:Label>
</div>




<%--<div style="border: 3px solid #555555; width: 400px; padding: 0px; border-radius: 5px; background-color: white;">

    <div style="border: 3px solid #555555; width: auto; background-color: #555555; color: white; padding: 0px;">
        <asp:Label runat="server" ID="LblTitle"></asp:Label>


    </div>
    <asp:HiddenField runat="server" ID="HidAccount" />
    <div style="padding: 3px;">
        <asp:TextBox runat="server" ID="TxtPost" TextMode="MultiLine" Rows="3" ClientIDMode="AutoID" Style="width: 380px;"></asp:TextBox><br />
        <div>
            <asp:Label runat="server" ID="LblResult" ViewStateMode="Disabled" Style="color: red;" Visible="false" Text="error"></asp:Label>
        </div>
        <asp:Button runat="server" ID="BtnReply" Text="SEND" CssClass="days active" Style="width: auto;" />

        <div runat="server" id="HTML_Fileuploader" >
        </div>
        <asp:Image runat="server" ID="ImgPost" style="max-height:200px;max-width:200px" /><br />
        <asp:HiddenField runat="server" ID="HidImageID" ClientIDMode="AutoID" />
        @<asp:TextBox runat="server" ID="TxtToAccountName"></asp:TextBox>
        <asp:CheckBox runat="server" ID="ChkPrivatePost" Text="post privato" TextAlign="Left" />

    </div>
    <asp:Label runat="server" ID="countBox" Text="140" ForeColor="Red" ></asp:Label>
</div>--%>
